<?php

namespace App\Transformers;

use App\Models\User;
use League\Fractal\TransformerAbstract;

class UserTransformer extends TransformerAbstract
{
    public function transform($user)
    {
        return [
            "id"=>$user['id'],
            "school_id"=>$user['school_id'],
            "coach_id"=>$user['coach_id'],
            "cardtype"=>$user['cardtype'],
            "idcard"=>$user['idcard'],
            "nickname"=>$user['name'],
            "sex"=>$user['sex'],
            "nation"=>$user['nation'],
            "userpic"=>$user['photo'],
            "photoid"=>$user['photoid'],
            "photoid_province"=>$user['photoid_province'],
            "family"=>$user['family'],
            "nationality"=>$user['nationality'],
            "schoolname" => $user->school->shortname,
            "stunum"=>$user['stunum'],
            "recnum"=>$user['recnum'],
            "phone"=>$user['phone'],
            "classnum"=>$user['classnum'],
            "area"=>$user['area'],
            "busitype"=>$user['busitype'],
            "cartype"=>$user['traintype'],
            "perdritype"=>$user['perdritype'],
            "drilicnum"=>$user['drilicnum'],
            "workunit"=>$user['workunit'],
            "postcode"=>$user['postcode'],
            "address"=>$user['address'],
            "temporarycode"=>$user['temporarycode'],
            "transaction"=>$user['transaction'],
            "applydate"=>$user['applydate'],
            "recruitstudent"=>$user['recruitstudent'],
            "height"=>$user['height'],
            "leftvision"=>$user['leftvision'],
            "rightvision"=>$user['rightvision'],
            "hearing"=>$user['hearing'],
            "upperlimb"=>$user['upperlimb'],
            "leftlimbs"=>$user['leftlimbs'],
            "rightlimbs"=>$user['rightlimbs'],
            "trunk"=>$user['trunk'],
            "stage"=>$user['stage'],
            "colorvision"=>$user['colorvision'],
            "webstudy"=>$user['webstudy'],
            "isfeatures"=>$user['isfeatures'],
            "created_at"=>$user['created_at'],
            "updated_at"=>$user['updated_at'],
            "sendcard"=>$user['sendcard'],
            "iccard"=>$user['iccard'],
            "fingerprintid"=>$user['fingerprintid'],
            "inscode"=>$user['inscode'],
            "fstdrilicdate"=>$user['fstdrilicdate'],
            "graduation"=>$user['graduation'],
            "graduation_time"=>$user['graduation_time'],
            "old_schoo_id"=>$user['old_schoo_id'],
            "isexist"=>$user['isexist'],
            "chargemode"=>$user['chargemode'],
            "paymode"=>isset($user->service) && $user->service ? $user->service->paymode : 0,
            "service_id"=>$user['service_id'],
            "km2period"=>$user['km2period'],
            "km3period"=>$user['km3period'],
            "pickupnum"=>$user['pickupnum'],
            "idcard_serial_number"=>$user['idcard_serial_number'],
            "should_price"=>$user['should_price'],
            "cheap_price"=>$user['cheap_price'],
            "cheap_comment"=>$user['cheap_comment'],
            "outlets_id"=>$user['outlets_id'],
            'sstc'=>$user['sstc'],
            'config'=>$user->config,
            'km2sumperiod'=>isset($user->syllaus_time) && $user->syllaus_time ? $user->syllaus_time->km2sumperiod : 0,
            'km2accomplish'=>isset($user->syllaus_time) && $user->syllaus_time ? $user->syllaus_time->km2accomplish : 0,
            'km3sunperiod'=>isset($user->syllaus_time) && $user->syllaus_time ? $user->syllaus_time->km3sumperiod : 0,
            'km3accomplish'=>isset($user->syllaus_time) && $user->syllaus_time ? $user->syllaus_time->km3accomplish : 0,
            'pickupnum2'=>isset($user->student_count) && $user->student_count ? $user->student_count->pickupnum : 0,
            'pickupsum'=>isset($user->student_count) && $user->student_count ? $user->student_count->pickupsum : 0,
            'pickupaccomplish'=>isset($user->student_count) && $user->student_count ? $user->student_count->pickupaccomplish : 0,
            'userId'=>$user->userId,
            'sub2total'=>$user->subinfo['sub2total'],
            'sub3total'=>$user->subinfo['sub3total'],
            'sub2period'=>$user->subinfo['sub2period'],
            'sub3period'=>$user->subinfo['sub3period'],
        ];

    }
}
